import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Solution888 {
    public int[] fairCandySwap(int[] aliceSizes, int[] bobSizes) {
        int sum1=Arrays.stream(aliceSizes).sum();
        int sum2=Arrays.stream(bobSizes).sum();
        int t=(sum1-sum2)/2;
        Map<Integer,Integer> map=new HashMap<>();
        for (int i=0;i<bobSizes.length;i++){
            map.put(bobSizes[i],i);
        }
        for (int i=0;i<aliceSizes.length;i++){
            if (map.containsKey(aliceSizes[i]-t)){
                return new int[]{aliceSizes[i],aliceSizes[i]-t};
            }
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution888().fairCandySwap(new int[]{1,2},new int[]{2,3})));
    }
}
